Search Results: "Romain Francoise"

1 March 2008

Romain Francoise: Fast directory navigation

About a year ago I stumbled upon this post which mentions the following shell keybindings: M-- for pushd .. and M-= for popd. Since the dash and equal signs are very conveniently placed next to each other, this allows fast directory navigation with accessible keystrokes and is especially convenient to move up in the directory hierarchy. Very neat.

Of course I use zsh and not bash, so I had to "port" this hack to zsh, which resulted in somewhat obscure code compared to the bash version:
function up-one-dir   set -E; pushd ..; set +E; zle redisplay; zle -M  pwd   
function back-one-dir set -E; popd; set +E; zle redisplay; zle -M pwd
zle -N up-one-dir
zle -N back-one-dir
bindkey "^[-" up-one-dir
bindkey "^[=" back-one-dir
Not so pretty, but it works. The only problem is that I do most of my shell interaction through shell-mode in Emacs, not in zle-capable terminals. So I also had to write a shell-mode version, which turned out to be even uglier because I basically had to rip off the shell-resync-dirs code to handle comint interaction and directory tracking. Here it is in all its glory:
(defun ore-shell-dirnav (direction)
(interactive)
(let* ((proc (get-buffer-process (current-buffer)))
(pmark (process-mark proc))
(cmd (if (eq direction 'up) "pushd .." "popd")))
(goto-char pmark)
(sit-for 0)
(comint-send-string proc cmd)
(comint-send-string proc "\n")
(set-marker pmark (point))
(let ((pt (point))
(regexp
(concat
(if comint-process-echoes
(concat "\\(" (regexp-quote cmd) "\n\\)")
"\\(\\)")
"\\(.+\n\\)")))
(insert "\n")
(backward-char 1)
(while (not (looking-at regexp))
(accept-process-output proc)
(goto-char pt)))
(goto-char pmark)
(delete-char 1)
(let* ((dl (buffer-substring (match-beginning 2) (1- (match-end 2))))
(dl-len (length dl))
(ds '())
(i 0))
(delete-region (match-beginning 2) (1- (match-end 2)))
(while ( i dl-len)
(string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
(setq ds (cons (concat comint-file-name-prefix
(substring dl (match-beginning 1)
(match-end 1)))
ds))
(setq i (match-end 0)))
(let ((ds (nreverse ds)))
(condition-case nil
(progn (shell-cd (car ds))
(setq shell-dirstack (cdr ds)
shell-last-dir (car shell-dirstack))
(shell-dirstack-message))
(error (message "Couldn't cd")))))))

(defun ore-shell-dirnav-up ()
(interactive)
(ore-shell-dirnav 'up))

(defun ore-shell-dirnav-down ()
(interactive)
(ore-shell-dirnav 'down))

(define-key shell-mode-map (kbd "M--") 'ore-shell-dirnav-up)
(define-key shell-mode-map (kbd "M-=") 'ore-shell-dirnav-down)
Phew. It's a lot of code for a seemingly simple feature, but the time it saves me probably adds up to a few hours per year, so it's worth it.

23 February 2008

Romain Francoise: Shared links for 2008-02-23

22 February 2008

Romain Francoise: Shared links for 2008-02-22

18 February 2008

Romain Francoise: All in the little things

This week's Emacs has a (small) new feature which I find pretty neat; when you search for a string that cannot be found, the failing part gets highlighted in the prompt:



Since isearch is the most efficient way of moving around (at least for long distance jumps) in Emacs buffers, being able to correct typos immediately is essential and this tiny change helps a lot!

(Oh, and there's also a new M-x emacs-uptime command. Just so you know.)

16 February 2008

Adeodato Sim : Non-interactively starting a screen with several windows

With /usr/bin/screen -dm you can start a screen non-interactively, eg. from cron, passing the command to run and its arguments as normal arguments:
  @reboot    screen -dm rtorrent -p 12345-12346
However, I wanted to start from cron a screen that would run various commands, each in its own window. AFAIK you can’t do this with a simple invocation, but you can prepare a custom screenrc file that defines which commands to run, with the screen command. For example:
  % cat ~/.screenrc_foo
  escape "^Oo"
  startup_message off
  hardstatus alwayslastline "%w"
  screen 0 command0 -x -y
  screen 1 command1 -z -w
  screen -t windowname 2 command2
  screen -t windowname 3 sh -c 'cd ~/quux && ./wrapper.sh'
Then you start it from cron like this:
  @reboot    screen -dm -c ~/.screenrc_foo
Thanks to Luca Capello and Romain Francoise in #debian-devel for the tip. Update: Laurence J. Lane points on IRC the -X option to screen, so you could do without the screenrc file and do it like this:
  % screen -dmS NAME command0 -x -y
  % screen -S NAME -X screen command1 -z -w
  % screen -S NAME -X screen -t windowname command2
  ...

14 February 2008

Romain Francoise: Shared links for 2008-02-15

Romain Francoise: So what's wrong with 1975 programming?

I enjoyed reading the ArchitectNotes on the Varnish wiki:
Take Squid for instance, a 1975 program if I ever saw one: You tell it how much RAM it can use and how much disk it can use. It will then spend inordinate amounts of time keeping track of what HTTP objects are in RAM and which are on disk and it will move them forth and back depending on traffic patterns.

Well, today computers really only have one kind of storage, and it is usually some sort of disk, the operating system and the virtual memory management hardware has converted the RAM to a cache for the disk storage.

So what happens with squid's elaborate memory management is that it gets into fights with the kernel's elaborate memory management, and like any civil war, that never gets anything done.
Varnish was designed by FreeBSD developer Poul-Henning Kamp. There is something to be said about user-space apps designed by kernel developers: they're always super fast because kernel developers know how to make the most of the system, having spent hours optimizing the kernel itself for some usage patterns.

This is why git (designed by Linus Torvalds, for those of you who've lived under a rock for the past three years) is so much faster than other comparable systems, for example. It uses tricks such as giving the O_NOATIME flag to open() to avoid updating access times on files where it knows that they don't matter, and it's a "huge time-saver". (Of course, you can also just mount your partitions with noatime and enjoy a similar performance boost in all applications!)

9 February 2008

Romain Francoise: emacs-snapshot 20080209-1

Now internally based on Unicode, with a new Xft-capable font backend, D-Bus integration, built-in EasyPG, XEmbed goodness, etc. And legions of bugs waiting to bite you. Get it from here as usual.

We also have a (completely fabricated) screenshot of the new font backend, for your viewing pleasure:

Romain Francoise: Shared links for 2008-02-09

8 February 2008

Romain Francoise: Quicksand, Saint-Michel, and a tip

My CC-licensed photo Quicksand is featured this morning on the front page of openDemocracy, illustrating this article about the US presence in Afghanistan and Iraq.

I took this picture in the summer of 2006 in Saint-Michel bay. At low tide it's possible to cross the bay on foot with a guide, from the shore to the island, a pleasant few kilometers of flat sand with a spectacular view of the Mont. Sadly, every year tourists attempt the trip unaccompanied, get stuck in the dangerous quicksands and drown when the rising tide enters the bay and completely fills it in mere minutes.

(If you ever get caught in that kind of quicksand, here's a survival tip: the key is to lie flat either on your back or on your stomach so that the bulk of your weight is supported by your upper body pressed flat against the sand. Then you just have to crawl forward with your arms and shoulders until your legs are freed from the sand.)

1 February 2008

Romain Francoise: Recent movies (5)

(Note: this post had been sitting in my drafts folder for some time so some of these are not so recent. I thought I'd mention them anyway.)

29 January 2008

Romain Francoise: Shared links for 2008-01-29

21 January 2008

Romain Francoise: Shared links for 2008-01-21

20 January 2008

Romain Francoise: Everybody loves xkcd

Even Phil Zimmermann.

15 January 2008

Romain Francoise: Shared links for 2008-01-15

13 January 2008

Romain Francoise: Elevate myself

Last week I signed up for my third year of Flickr. It's been two years since I got my first digital camera and I've been pretty happy with it, but I use it a lot less than I initially thought I would. I've got to work on that in 2008!

To celebrate, here are my favorites of the past two years from my own Flickr stream:

 In the meadow (again) Window to the sky The Way Lovers over Lake Annecy Red T Sunset on Saint-Michel bay (2) Rock on rock You lookin' at me? Wireless Ce ciel   mes pieds Shine on me Minikaribu on the train back to France Street light as fairground, second try Angel Green There are heroes in the seaweed Glass ball (1) Sand, wind and sunlight

All my photos are published under a Creative Commons by-nc-sa 2.0 license.

10 January 2008

Romain Francoise: Shared links for 2008-01-10

8 January 2008

Romain Francoise: Shared links for 2008-01-08

6 January 2008

Romain Francoise: Flickr favorites RSS feeds

Sometime in the last few weeks Flickr started offering RSS feeds of favorites; as far as I can tell they didn't announce it anywhere. This was my #1 feature request. Yay!

3 January 2008

Romain Francoise: Shared links for 2008-01-03

Next.

Previous.